import { httpR2 } from "@/utils/http";
import type { LoginDTO, OauthLoginResult } from "@/types/login.d";

/**
 * 分页请求书本信息
 * @param query
 * @returns
 */
export const wxloginApi = (query: LoginDTO) => {
  return httpR2<OauthLoginResult>({
    method: "POST",
    url: "/auth/customLogin/wxlogin",
    data: {
      ...query,
    },
  });
};

export const wxloginGetCode = () => {
  return new Promise((resolve, reject) => {
    uni.login({
      success: async (res) => {
        console.log("用户进行登录，获得回调参数res：", res);
        resolve(res);
      },
      fail: (err) => {
        console.error("登录失败:", err);
        reject(err); // 登录失败，reject 错误信息
      },
    });
  });
};
